package ru.chaykin.additionalinfo;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

import ru.chaykin.OpenGLSceneView;
import ru.chaykin.R;
import ru.chaykin.viewobject.ViewObject;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.GridView;
import android.widget.Toast;

public class AdditionalInfoActivity extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);	//Убрать title bar
		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
		
		setContentView(R.layout.additional_info_layout);
		GridView grid = (GridView) findViewById(R.id.additionalInfoGrid);
		try {
			String[] midData = ViewObject.getMIDInfo(OpenGLSceneView.getSelectedObjectId());
			grid.setAdapter(new AdditionalInfoGridAdapter(getApplicationContext(), midData));//new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, result));
			grid.setEnabled(false);
		} catch (UnsupportedEncodingException e) {
			//TODO строку в ресурсы
			Toast.makeText(getApplicationContext(), "Ошибка преобразования файла", Toast.LENGTH_LONG).show();
			finish();
		} catch (FileNotFoundException e) {
			//TODO строку в ресурсы
			Toast.makeText(getApplicationContext(), "Файл не найден", Toast.LENGTH_LONG).show();
			finish();
		} catch (IOException e) {
			//TODO строку в ресурсы
			Toast.makeText(getApplicationContext(), "Ошибка ввода-вывода", Toast.LENGTH_LONG).show();
			finish();
		} catch (Exception e) {
			//TODO строку в ресурсы
			Toast.makeText(getApplicationContext(), "Неизвестная ошибка", Toast.LENGTH_LONG).show();
			finish();
		}
	}
}
